﻿Imports System.Data.SqlClient

Public Class QuanBUS
    Public Shared Function GetAll() As List(Of QuanDTO)
        Dim listQuan As List(Of QuanDTO)

        listQuan = QuanDAO.GetAll()

        Return listQuan
    End Function


    Public Shared Sub Insert(ByVal quan As QuanDTO)
        Dim parameters(1) As SqlParameter

        Dim para As SqlParameter = New SqlParameter("TenQuan", SqlDbType.NVarChar)
        para.Direction = ParameterDirection.Input
        para.Value = quan.strTenQuan
        parameters(0) = para

        Dim para1 As SqlParameter = New SqlParameter("SoLuongNhaHienTai", SqlDbType.Int)
        para1.Direction = ParameterDirection.Input
        para1.Value = 0
        parameters(1) = para1

        QuanDAO.Insert(parameters)
    End Sub
    Public Shared Sub delete_Quan(ByVal maquan As Integer)
        Dim parameters(1) As SqlParameter

        Dim para As SqlParameter = New SqlParameter("MaQuan", SqlDbType.Int)
        para.Direction = ParameterDirection.Input
        para.Value = maquan
        parameters(0) = para

        QuanDAO.Delete(para)
    End Sub
 
   
    Public Shared Sub Update(ByVal qd As QuanDTO)

        Dim para As SqlParameter = New SqlParameter("MaQuan ", SqlDbType.Int)
        para.Direction = ParameterDirection.Input
        para.Value = qd.iMaQuan

        Dim para1 = New SqlParameter("TenQuan ", SqlDbType.Int)
        para1.Direction = ParameterDirection.Input
        para1.Value = qd.strTenQuan


        ThamSoDAO.Update1(para, para1)

    End Sub

    Public Shared Function KiemTraDayDu(ByVal TenQuan As String)
        Dim kq As Boolean
        If Not TenQuan = "" Then

            kq = True
        Else
            kq = False
        End If

        Return kq
    End Function
End Class
